﻿@model DrillOnline.Services.DrillScenarios

@{
    Layout = "_Layout.cshtml";
    ViewBag.Title = "CtrlPanel";
}
<style type="text/css">
    html, body
    {
        margin: 0px 0px;
        width: 100%;
        height: 100%;
    }

    iframe
    {
        margin: 0px 0px;
        width: 100%;
        height: 100%;
    }
</style>

<script type="text/javascript">
    function iframeHeight() {
        document.getElementById('iframeId').height = "100%";
    }
</script>
<script src="~/Scripts/jquery-2.0.3.min.js"></script>
<script src="~/Scripts/jquery-ui-1.10.3.js"></script>
<script src="~/Scripts/jquery.signalR-2.0.0.min.js"></script>

<script src="~/Scripts/arttemplate.js"></script>

<script src="~/signalr/hubs"></script>

<script type="text/javascript">
    $(function () {
        var scenario = $.connection.drillEventHub;
        scenario.client.Broadcast = function (result) {
            for (var i = result.SceneList.length - 1; i > -1; i--) {
                var sc = result.SceneList[i];
                if (sc.ATYPE == '') continue;
                window.open("/Media/Index/" + sc.ID, 'innerMedia', null, true);
                break;
            }
        };

        scenario.client.StatusChange = function (Now, IsReady, Status) {
            //updateStatus(Now, IsReady, Status);
        }
        $.connection.hub.start().done(function () {
            scenario.server.queryOldEvents();
        });
    });
    // This optional function html-encodes messages for display in the page.
    function updateStatus(Now, IsReady, Status) {
        var t = "";
        var s = 0; var c = 0;
        if (!IsReady) {
            t = "未开始";
            s = 0;
        } else {
            s = 1;
            c = Status;
            if (Status == 0) {
                t = "已停止";
            } else if (Status == 1) {
                t = "已暂停";
            } else if (Status == 2) {
                t = "进行中";
            }
        }
        //$("#playstatus").text(t);
        //if (IsReady) {
        //    $('#chatbox').slideDown();
        //} else {
        //    $('#chatbox').slideUp();
        //    navigate("Index");
        //}
    }
</script>

<iframe name="innerMedia" frameborder="0" border="0" style="width: 100%; height: 100%;" scrolling="no" src="about:blank"></iframe>
